MDX 语法学习
MDX 是一种书写格式,允许在 Markdown 文档中无缝地插入 JSX 代码。 你还可以导入(import)组件,例如交互式图表或弹框,并将它们 嵌入到内容当中。
以下是一个 Markdown 中嵌入 JSX 的示例。
This is JSX
它还能嵌入一个实时代码编辑器,如下所示:
实时编辑器
结果
Loading...
如果需要内嵌 HTML,如锚点链接或粗体类型,可以使用 <pre>
标记、<code>
标记或 <CodeBlock>
组件。
Input: 1 2 3 4
Output: "366300745"
显示多编程语言代码选项卡的示例
- JavaScript
- Python
- Java
function helloWorld() {
console.log('Hello, world!');
}
def hello_world():
print 'Hello, world!'
class HelloWorld {
public static void main(String args[]) {
System.out.println("Hello, World");
}
}
告示
除了支持 Markdown 的基本语法外,还可以使用 remark-admonitions 和 MDX 来支持告示 (Admonition)功能。 告示由 3 个冒号开头。
示例:
备注
Some content with markdown syntax
. Check this api
.
提示
Some content with markdown syntax
. Check this api
.
信息
Some content with markdown syntax
. Check this api
.
警告
Some content with markdown syntax
. Check this api
.
危险
Some content with markdown syntax
. Check this api
.
在告示里面也是支持使用 Table 的
Use tabs in admonitions
- Apple
- Orange
- Banana
This is an apple 🍎
This is an orange 🍊
This is a banana 🍌